package activity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

// Order class
public class Transaction implements Serializable{
	
	private int id;
	private double total;
	private Collection<Ticket> lineItems;
	
	public int getID()
	{
		return id;
	}
	
	public void setID(int id)
	{
		this.id = id;
	}
	
	public double getTotal()
	{
		return total;
	}
	
	public void setTotal(double total)
	{
		this.total = total;
	}
	
	public void addPurchase (String product, int quantity, double price)
	{
		if (lineItems == null)
		{
			lineItems = new ArrayList<Ticket>();
		}
		Ticket item = new Ticket();
		item.setTransaction(this);
		item.setProduct(product);
		item.setQuantity(quantity);
		item.setSubtotal(quantity * price);
		lineItems.add(item);
		total += quantity * price;
	}
	
	public Collection <Ticket> getLineItems()
	{
		return lineItems;
	}
	
	public void setLineItems (Collection<Ticket> lineItems)
	{
		this.lineItems = lineItems;
	}
	

}
